package com.tanhua.admin.task;

import com.tanhua.admin.service.AnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.expression.ParseException;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class AnalysisTask {
    @Autowired
    private AnalysisService analysisService;

    @Scheduled(cron = " 0/5 * * * * ? ")
    public void analysis() {
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        System.err.println("当前时间=" + format);
        try {
            analysisService.analysis();
            System.err.println("结束统计");
        } catch (ParseException | java.text.ParseException e) {
            e.printStackTrace();
        }
    }
}
